package cn.xinfei.xdecision.common.service.component.decisiontree;

import cn.xinfei.xdecision.common.model.common.PageResult;
import cn.xinfei.xdecision.common.model.common.ResponseEntityDto;
import cn.xinfei.xdecision.common.model.common.requestParam.AssemblyRuleCodeReq;
import cn.xinfei.xdecision.common.model.common.requestParam.StatusParam;
import cn.xinfei.xdecision.common.model.component.decisiontree.DecisionTreeVersion;
import cn.xinfei.xdecision.common.model.component.decisiontree.vo.DecisionTreeVersionListVo;
import cn.xinfei.xdecision.common.model.component.decisiontree.vo.DecisionTreeVersionVo;
import cn.xinfei.xdecision.common.utils.enums.enginex.ComponentVersionStatusEnum;
import com.baomidou.mybatisplus.extension.service.IService;

import java.util.List;

public interface DecisionTreeVersionService extends IService<DecisionTreeVersion> {

    /**
     * 通过决策树code集合，查询版本集合
     *
     * @param decisionTreeCodes 决策树code
     * @param status            版本状态
     * @return {@link DecisionTreeVersionVo 决策树版本}
     * @see ComponentVersionStatusEnum
     */
    List<DecisionTreeVersionVo> queryVersionByTreeCodes(List<String> decisionTreeCodes, Integer status);
    List<DecisionTreeVersionVo> queryVersionByTreeCodes(String decisionTreeCode, Long versionNo);

    List<String> queryFieldEnByVersionId(Long versionId);

    List<DecisionTreeVersionVo> queryVersionListByDecisionTreeId(Long decisionTreeId);

    void addVersionList(List<DecisionTreeVersionVo> versionList);

    boolean updateVersion(DecisionTreeVersionVo version);

    boolean updateStatus(StatusParam statusParam);

    // runner
    DecisionTreeVersionVo queryById(Long id);

    List<String> queryFieldEnByVersionIdRunner(Long versionId);

    /**
     * 锁定规则
     */
    void lockDecisionTree(Long versionId);

    /**
     * 通过规则code查看版本列表
     *
     * @param req 规则code
     * @return 版本集合
     */
    ResponseEntityDto<PageResult<List<DecisionTreeVersionListVo>, DecisionTreeVersion>> listByDecisionTreeCode(AssemblyRuleCodeReq req);

    Long checkAndAddVersion(DecisionTreeVersionVo version);

    Boolean saveOrUpdateVersion(DecisionTreeVersionVo version);
}

